package com.jwsoft.manager.core.gateway.controller;

import com.bifang.assistant.common.constants.Validators;
import com.bifang.engine.assistant.core.domain.AppResponse;
import com.bifang.engine.protect.core.annotation.Idempotent;
import com.github.pagehelper.PageInfo;
import com.jwsoft.manager.common.vo.eduArea.EduAreaKeyVO;
import com.jwsoft.manager.common.vo.eduArea.EduAreaQueryVO;
import com.jwsoft.manager.common.vo.eduArea.EduAreaVO;
import com.jwsoft.manager.core.integration.EduAreaIntegration;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 行政区划参数维护网关
 *
 * @author dlb
 * @since 2023-02-09
 */
@RestController
@RequestMapping(value = "/doc/api")
@Tag(name = "行政区划参数维护", description = "行政区划参数维护")
public class EduAreaController {

    @Autowired
    public EduAreaIntegration eduAreaIntegration;

    @Operation(summary = "行政区划参数维护分页查询",description = "行政区划参数维护分页查询")
    @PostMapping(value = "/eduAreaLocalManage0001", produces = "application/json;charset=UTF-8")
    public AppResponse<PageInfo<EduAreaVO>> getList(@RequestBody @Validated EduAreaQueryVO vo) {
        return AppResponse.successData(eduAreaIntegration.getList(vo));
    }

    @Operation(summary = "行政区划参数维护根据主键查询详情",description = "行政区划参数维护根据主键查询详情")
    @PostMapping(value = "/eduAreaLocalManage0002", produces = "application/json;charset=UTF-8")
    public AppResponse<EduAreaVO> getById(@RequestBody @Validated EduAreaKeyVO vo) {
        return AppResponse.successData(eduAreaIntegration.getById(vo));
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "行政区划参数维护新增",description = "行政区划参数维护新增")
    @PostMapping(value = "/eduAreaLocalManage0004", produces = "application/json;charset=UTF-8")
    public AppResponse<EduAreaVO> add(@RequestBody @Validated(value = {Validators.Add.class}) EduAreaVO vo) {
        return AppResponse.successData(eduAreaIntegration.add(vo));
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "行政区划参数维护修改",description = "行政区划参数维护修改")
    @PostMapping(value = "/eduAreaLocalManage0005", produces = "application/json;charset=UTF-8")
    public AppResponse<EduAreaVO> edit(@RequestBody @Validated(value = {Validators.Edit.class}) EduAreaVO vo) {
        return AppResponse.successData(eduAreaIntegration.edit(vo));
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "行政区划参数维护删除",description = "行政区划参数维护删除")
    @PostMapping(value = "/eduAreaLocalManage0006", produces = "application/json;charset=UTF-8")
    public AppResponse del(@RequestBody @Validated EduAreaKeyVO vo) {
        eduAreaIntegration.del(vo);
        return AppResponse.successMsg("删除成功！");
    }
}
